package com.order.mapper;

import com.usian.order.Order;
import com.usian.pay.AliPay;
import com.usian.scenic.Scenic;
import com.usian.travelSchedule.TravelSchedule;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderMapper {
    @Select("   SELECT * FROM tb_order WHERE user_id = #{id} and status = #{status}")
    List<Order> selectOrder(Integer id,Integer status);
    @Select("   SELECT * FROM tb_order WHERE user_id = #{id} and status = #{status}")
    List<Order> selectTakeOrder(Integer id, Integer status);
    @Select("   SELECT * FROM scenic_spot_info WHERE address = #{s}")
    List<Scenic> selectScenicOrder(String s);
    @Select("select * from travel_schedule where id=#{addressId}")
    TravelSchedule selectTravel(Integer addressId);
    @Update("update tb_order set order_status = #{status} where id = #{id}")
    int deleteStatus(Integer id, int status);
    @Insert("insert into tb_order(user_id,address,order_status,status,amount,address_id,category,communication,time) " +
            "values(#{userId},#{address},#{orderStatus},#{status},#{amount},#{addressId},#{category},#{communication},#{time})")
    int saveOrder(Order order);
    @Update("update tb_order set order_status = 3 where id = #{id}")
    Integer selectTravelOrderStatuslook(Integer id);
    @Select("SELECT * FROM tb_order WHERE id = #{id} and order_status = #{i}")
    Order selectOrders(Integer id, int i);
    @Select("SELECT * FROM ali_pay WHERE out_trade_no = #{id}")
    AliPay selectPay(Integer id);
    @Insert("insert into appraise(own_id,lessor_id,scores,content) values(#{userid},#{designerId},#{scores},#{content})")
    Integer saveaddressId(Integer designerId, Integer userid, Double scores, String content);

    @Select("select * from tb_order where order_status = #{orderStatus}")
    List<Order> getUnacceptedOrders(Integer orderStatus);

    @Update("update tb_order set order_status = #{orderStatus}, accept_id = #{userId} where id = #{id}")
    int updateByStatus(Integer id, Integer orderStatus,Integer userId);
    @Update("update tb_user set service_times = service_times+1 where id = #{designerId}")
    void updateserviceTimes(Integer designerId);
    @Select("SELECT * FROM tb_order WHERE accept_id = #{id} and status = #{status}")
    List<Order> selectTakeOrders(Integer id, Integer status);
    @Update("update tb_order set order_status = 4 where id = #{id}")
    Integer skipPayment(Integer id);
}
